package com.rdc.qingkou.presenter;

import com.rdc.qingkou.base.BasePresenterImpl;
import com.rdc.qingkou.model.TwoLevelCommentModel;
import com.rdc.qingkou.presenter.ipresenter.ITwoLevelPresenter;
import com.rdc.qingkou.ui.iview.ITwoLevelCommentView;
import com.rdc.qingkou.vo.CommentTwoLevelVO;

import java.util.List;


public class TwoLevelCommentPresenter extends BasePresenterImpl<ITwoLevelCommentView> implements ITwoLevelPresenter {

    private TwoLevelCommentModel model;

    public TwoLevelCommentPresenter() {
        model = new TwoLevelCommentModel(this);
    }


    @Override
    public void appreciate(int commentId) {
        model.appreciate(commentId);
    }

    @Override
    public void appreciateSuccess(int id, boolean flag) {
        if (isAttachView()) {
            getMvpView().appreciateSuccess(id, flag);
        }
    }

    @Override
    public void appreciateError(String message) {
        if (isAttachView()) {
            getMvpView().appreciateError(message);
        }
    }

    @Override
    public void sendTwoLevelComment(String input, int userId, int reviewerId, int parentCommentId, String reviewer) {
        model.sendTwoLevelComment(input, userId, reviewerId, parentCommentId, reviewer);
    }


    @Override
    public void sendTwoLevelCommentSuccess(CommentTwoLevelVO comment) {
        if (isAttachView()) {
            getMvpView().sendTwoLevelCommentsSuccess(comment);
        }
    }

    @Override
    public void sendTwoLevelCommentError(String message) {
        if (isAttachView()) {
            getMvpView().sendTwoLevelCommentsError(message);
        }
    }

    @Override
    public void getTwoLevelComment(int parentCommentId, int currentPage) {
        model.getTwoLevelComment(parentCommentId, currentPage);
    }

    @Override
    public void getTwoLevelCommentSuccess(List<CommentTwoLevelVO> recentList) {
        if (isAttachView()) {
            getMvpView().getTwoLevelCommentsSuccess(recentList);
        }
    }

    @Override
    public void getTwoLevelCommentError(String message) {
        if (isAttachView()) {
            getMvpView().getTwoLevelCommentsError(message);
        }
    }

    @Override
    public void clearDisposable() {
        model.clearDisposable();
    }
}
